package com.cloud.poetry.chatroom.controller;

import com.cloud.poetry.chatroom.component.ChatRoomServer;
import com.cloud.poetry.core.entity.ChatCacheUser;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author mengxj
 */
@RestController
@RequestMapping("chatroom")
public class ChatRoomController {

    @Resource
    private ChatRoomServer chatRoomServer;

    @GetMapping("onlineNum")
    public Integer onlineNum(){
        return this.chatRoomServer.getOnlineNum();
    }

    @GetMapping("onlineList/{uid}")
    public List<ChatCacheUser> onlineList(@PathVariable("uid") Long uid){
        return this.chatRoomServer.onlineList(uid);
    }

    @PostMapping("addUser")
    public void addUser(@RequestBody ChatCacheUser user) {
        this.chatRoomServer.addUser(user);
    }
}
